package com.Lyy.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
@PropertySource("classpath:jdbc.properties")
public class JdbcConfig {
    @Value("${jdbc.Driver}")
    private String DriverClassName;
    @Value("${jdbc.Url}")
    private String Url;
    @Value("${jdbc.Username}")
    private String Username;
    @Value("${jdbc.Password}")
    private String Password;

    @Bean
    public DruidDataSource GetDruidDataSource() {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName(DriverClassName);
        druidDataSource.setUrl(Url);
        druidDataSource.setUsername(Username);
        druidDataSource.setPassword(Password);
        return druidDataSource;
    }
}
